package com.longxi.tianjintianbao.ui.activity.department;

import android.content.Intent;
import android.support.v7.widget.RecyclerView;

import com.longxi.tianjintianbao.R;
import com.longxi.tianjintianbao.ui.base.BaseActivity;
import com.longxi.tianjintianbao.ui.presenter.department.DepartmentAtPresenter;
import com.longxi.tianjintianbao.ui.view.department.IDepartmentAtView;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;

public class DepartmentActivity extends BaseActivity<IDepartmentAtView, DepartmentAtPresenter> implements IDepartmentAtView {

    private String TAG = "DepartmentActivity";

    @Override
    protected int provideContentViewId() {
        return R.layout.activity_general_refresh_list;
    }

    @Override
    public void initData() {
        super.initData();
        mPresenter.setBar();
        mPresenter.initAdapter();
    }

    @Override
    public void initListener() {
        super.initListener();
        mRefreshLayout.setOnRefreshListener(new OnRefreshListener() {

            @Override
            public void onRefresh(RefreshLayout refreshLayout) {
                mPresenter.getDepartment();
            }

        });
        mPresenter.getDepartment();
        mTvRight.setOnClickListener(v -> mPresenter.toPersonnelActivity());
    }

    @Override
    protected DepartmentAtPresenter createPresenter() {
        return new DepartmentAtPresenter(this);
    }

    @Override
    public SmartRefreshLayout getRefreshLayout() {
        return mRefreshLayout;
    }

    @Override
    public RecyclerView getRvContent() {
        return mRvContent;
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if(resultCode != RESULT_OK){
            return;
        }
        mPresenter.onActivityResult(requestCode, resultCode, data);
    }
}
